Skip to content

Ascent_Descent information at start #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 6, 2021
Merged

Ascent_Descent information at start #149

merged 2 commits into from
Apr 6, 2021

Conversation

jposada202020
Copy link
Contributor

This will make info on the font ascent/descent info available for the class, avoiding unnecessary calls to calculate this during the script

@jposada202020 jposada202020 added the enhancement New feature or request label Apr 1, 2021
Copy link
Contributor

@lesamouraipourpre lesamouraipourpre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

You could also remove the _get_ascent function and it's only call:

diff --git a/adafruit_display_text/__init__.py b/adafruit_display_text/__init__.py
index e6f2c1d..246f54e 100644
--- a/adafruit_display_text/__init__.py
+++ b/adafruit_display_text/__init__.py
@@ -245,7 +245,7 @@ class LabelBase(Group):
         if self.base_alignment:
             self._y_offset = 0
         else:
-            self._y_offset = self._get_ascent() // 2
+            self._y_offset = self._ascent // 2
 
     def _get_ascent_descent(self) -> Tuple[int, int]:
         """ Private function to calculate ascent and descent font values """
@@ -268,9 +268,6 @@ class LabelBase(Group):
                 descender_max = max(descender_max, -this_glyph.dy)
         return ascender_max, descender_max
 
-    def _get_ascent(self) -> int:
-        return self._get_ascent_descent()[0]
-
     @property
     def font(self) -> None:
         """Font to use for text display."""

@jposada202020
Copy link
Contributor Author

@lesamouraipourpre Good point will do. Thanks for reviewing :) and the recommendation

Copy link
Contributor

@lesamouraipourpre lesamouraipourpre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice simplification you've implemented.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks @jposada202020.

And thank you @lesamouraipourpre for testing!

@FoamyGuy FoamyGuy merged commit 70bff04 into adafruit:master Apr 6, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 7, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground to 4.3.3 from 4.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_CircuitPlayground#104 from kattni/main-fix
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_DHT to 3.6.0 from 3.5.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_DHT#68 from yeyeto2788/master
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_FocalTouch to 1.2.7 from 1.2.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_FocalTouch#20 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_RockBlock to 1.3.3 from 1.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_RockBlock#21 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 1.9.3 from 1.9.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#32 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_AdafruitIO to 5.2.4 from 5.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_AdafruitIO#68 from brentru/validate-feed-keys-used
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_AVRprog to 1.3.7 from 1.3.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_AVRprog#21 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_BitmapSaver to 1.1.6 from 1.1.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_BitmapSaver#14 from kmatch98/patch-2
  > "Increase duplicate code check threshold "
  > Merge pull request adafruit/Adafruit_CircuitPython_BitmapSaver#17 from FoamyGuy/pylintrc

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_Radio to 0.3.5 from 0.3.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE_Radio#15 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_BoardTest to 1.2.6 from 1.2.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_BoardTest#15 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_datetime to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_datetime#8 from adafruit/jepler-integer-total_seconds
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.18.3 from 2.18.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#150 from jposada202020/advanced_example
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#149 from jposada202020/optimizing_getting_font_info

Updating https://github.com/adafruit/Adafruit_CircuitPython_RGBLED to 1.1.5 from 1.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_RGBLED#15 from adafruit/dherrada-patch-1
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_RSA to 1.2.4 from 1.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_RSA#18 from adafruit/linting
  > "Increase duplicate code check threshold "
@jposada202020 jposada202020 deleted the optimizing_getting_font_info branch June 13, 2021 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants